package Demo;
public class TestStudent {
    //求最大值的方法
    public static int getMax(int[]arr){
        int max=arr[0];
        for (int i = 0; i <arr.length ; i++) {
            if(arr[i]>max){
                max=arr[i];
            }
        }
        return max;
    }
    //求最小值方法
    public static int getMin(int[]arr){
        int min=arr[0];
        for (int i = 0; i <arr.length ; i++) {
            if(arr[i]<min){
                min=arr[i];
            }
        }
        return min;
    }
    public static void main(String[] args)
    {
        //创建5个学生对象
        Student student1=new Student(20201001,"李一","男",18,65);
        Student student2=new Student(20201002,"李二","女",19,75);
        Student student3=new Student(20201003,"李三","男",20,85);
        Student student4=new Student(20201004,"李四","男",21,95);
        Student student5=new Student(20201005,"李五","女",22,100);
         //求平均值
        int sum=student1.getsJava()+student2.getsJava()+student3.getsJava()+student4.getsJava()+student5.getsJava();
        double ave=sum/5.0;
        System.out.println("平均成绩："+ave);
        //学生成绩数组
        int[] arr = {student1.getsJava(),student2.getsJava(),student3.getsJava(),student4.getsJava(),student5.getsJava()};

        System.out.println("成绩最大值:"+getMax(arr));
        System.out.println("成绩最小值："+getMin(arr));
    }
}
